﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑评论</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link href="../../../layuiadmin/style/mystyle.css" rel="stylesheet" />
    <script src="../../../layuiadmin/artdialog/artDialog.js?skins=chrome"></script>
    <script src="../../../layuiadmin/lib/jquery.min.js"></script>
    <script src="../../../layuiadmin/lib/api.js"></script>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/lib/common.js"></script>
    <!--编辑器-->
    <link href="../../../layuiadmin/kindeditor/themes/default/default.css" rel="stylesheet" />
    <script src="../../../layuiadmin/kindeditor/kindeditor-all.js"></script>
    <script src="../../../layuiadmin/kindeditor/lang/zh-CN.js"></script>
    <script src="../../../layuiadmin/lib/system.js"></script>

    <script>
        sys_islogin();
    </script>
</head>
<body>

    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
        <div style="margin-bottom: 45px;">
            <input type="hidden" id="RESOURCEID" name="RESOURCEID" value="" />
            <input type="hidden" id="TYPE" name="TYPE" value="" />
            <input type="hidden" id="COMMENTID" name="COMMENTID" value="" />
            <div class="layui-form-item">
                <label class="layui-form-label">内容</label>
                <div>
                    <textarea name="DETAIL" id="DETAIL" style=" height: 580px;width:85%;" autocomplete="off" class="layui-textarea" placeholder=""></textarea>
                    
                </div>
            </div>
        </div>


        <div class="layui-form-item layui-layout-admin" style="text-align:center;">
            <div class="layui-footer-new" style="background-color:#fff;">
                <button class="layui-btn" lay-submit lay-filter="save" id="save">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary" id="close">取消</button>
            </div>
        </div>
    </div>

    
    <script>
        //编辑器
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('textarea[name="DETAIL"]', {
                allowImageUpload: true,
                uploadJson: '/KindEditorMerber/UpLoadFiles',
                fileManagerJson: '/KindEditorMerber/FileManager',
                items: [
                    'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                    'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                    'insertunorderedlist', '|', 'emoticons', 'image', 'link']
            });

        });
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'upload'], function () {
            var $ = layui.$
                , form = layui.form, upload = layui.upload;

            //监听提交
            form.on('submit(save)', function (data) {
                var field = data.field; //获取提交的字段
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                data.field.DETAIL = editor.html(); //获取编辑框的值
                //提交 Ajax 成功后，关闭当前弹层并重载表格
                $.ajax({
                    url: "/TaskCommentMerber/AddTaskComment",    //请求的url地址
                    dataType: "json",   //返回格式为json
                    async: true,//请求是否异步，默认为异步，这也是ajax重要特性
                    data: { arg: JSON.stringify(field)},    //参数值
                    type: "POST",   //请求方式
                    beforeSend: function () {
                        //请求前的处理
                    },
                    success: function (data) {
                        //请求成功时处理
                        if (data.flag > 0) {
                            window.parent.location.reload();//刷新父页面
                            parent.layer.close(index); //再执行关闭
                        }                       
                        return layer.msg(data.message);
                    },
                    error: function (res) {
                        console.log(res);
                        layer.msg("添加失败，请联系技术人员");
                    }
                });

            });

            
        })

        
        //接收父页面的数据
        function child_fill_data(RESOURCEID, TYPE,COMMENTID,detail) {
            $("#RESOURCEID").val(RESOURCEID);
            $("#TYPE").val(TYPE);
            $("#COMMENTID").val(COMMENTID);
            editor.html(detail);
        };

        
        //关闭弹窗
        $("#close").on("click", function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });

    </script>
</body>
</html>